<template>
	<view class="chart-container">
		<!-- 自定义标题区域 -->
		<view class="chart-title">
			<text class="title-text">客群产品偏好top10</text>
		</view>
		<qiun-data-charts type="column" :opts="opts" :chartData="chartData" />
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				chartData: {},
				//您可以通过修改 config-ucharts.js 文件中下标为 ['column'] 的节点来配置全局默认参数，如都是默认参数，此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式，达到页面简洁的需求。
				opts: {
					color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
						"#ea7ccc"
					],
					padding: [15, 15, 0, 5],
					enableScroll: false,
					legend: {},
					xAxis: {
						disableGrid: true
					},
					yAxis: {
						data: [{
							min: 0
						}]
					},
					extra: {
						column: {
							barBorderRadius: [
								6,
								6,
								0,
								0
							],
							type: "meter",
							width: 30,
							activeBgColor: "#000000",
							activeBgOpacity: 0.08,
							meterBorder: 2,
							meterFillColor: "#EBFBD6"
						}
					}
				}
			};
		},
		created() {
			this.getServerData();
		},
		methods: {
			getServerData() {
				//模拟从服务器获取数据时的延时
				setTimeout(() => {
					//模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
					let res = {
						categories: ["小王", "张三", "李四", "赵五", "王五", "小沈", "小四", "小五","张九"],
						series: [{
								name: "目标值",
								data: [35, 36, 31, 33, 13, 34,35, 36, 31,]
							},
							{
								name: "完成量",
								data: [18, 27, 21, 24, 6, 28,35, 40, 31,]
							}
						]
					};
					this.chartData = JSON.parse(JSON.stringify(res));
				}, 500);
			},
		}
	};
</script>
<style scoped>
	.chart-container {
		padding: 24rpx;
		box-sizing: border-box;
		background-color: #fff;
		/* margin: 20rpx; */
		/* border-radius: 8rpx; */
		margin-bottom: 24rpx;
	}

	.chart-wrapper {
		padding: 30rpx;
		background-color: #fff;
		/* border-radius: 16rpx; */
	}

	/* 自定义标题样式 */
	.chart-title {
		display: flex;
		justify-content: space-between;
		/* 标题左对齐，省略号右对齐 */
		align-items: center;
		padding: 0 20rpx 20rpx;
		/* 底部留出距离 */
		/* border-bottom: 1px solid #f5f5f5; */
		/* 底部分隔线 */
		/* margin-bottom: 20rpx; */
	}

	.title-text {
		font-size: 30rpx;
		font-weight: bold;
		color: #333;
		/* 标题深色 */
	}

	.more-icon {
		font-size: 36rpx;
		color: #999;
		/* 省略号浅色 */
		padding: 10rpx;
	}
</style>